<?php
class ProductReference extends SOAPWebServiceReference {

    public function __construct() {

        parent::__construct("http://vitche.com/projects/CommerceCore/Content/Product.svc?wsdl");
    }

    /**
     * Returns the count of available data items
     **/
    public function count() {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("Count", array('token' => $Session->getToken()));
        }

        return null;
    }

    public function countWithProductCategoryId($idProductCategory) {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("CountWithProductCategoryId", array('token' => $Session->getToken(), 'idProductCategory' => $idProductCategory));
        }

        return null;
    }

    public function select() {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {

            return $this->execute("Select", array('token' => $Session->getToken()));
        }

        return null;
    }

    public function selectWithProductCategoryId($idProductCategory) {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("SelectWithProductCategoryId", array('token' => $Session->getToken(), 'idProductCategory' => $idProductCategory));
        }

        return null;
    }

    /**
     * Selects a given range of product categories
     *
     * @param int $startFrom An index to select items from
     * @param int $length Count of items to select
     * @return Array
     **/
    public function selectRange($startFrom, $length) {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("SelectRange", array('token' => $Session->getToken(), 'startFrom' => $startFrom, 'length' => $length));
        }

        return null;
    }

    public function selectRangeWithProductCategoryId($startFrom, $length, $idProductCategory) {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("SelectRangeWithProductCategoryId", array('token' => $Session->getToken(), 'startFrom' => $startFrom, 'length' => $length, 'idProductCategory' => $idProductCategory));
        }

        return null;
    }

    public function selectWithId($id) {

        $Session = new Session();
        $Session = $Session->loadFromSession();

        if (isset($Session)) {
            return $this->execute("SelectWithId", array('token' => $Session->getToken(), 'id' => "" . $id));
        }

        return null;
    }
}
?>